<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    //1.模型关联的表
    protected $table = 'user';

    //2.表的主键
    public $primaryKey = 'user_id';

    //3.是否允许批量操作字段
    //protected $fillable = ['user_name'];
    protected $guarded = [];

    //4.是否维护create_at和update_at字段
    public $timestamps = false;

    //添加动态属性，关联角色模型
    public function role(){
        return $this->belongsToMany('app\Model\Role','user_role','user_id','role_id');
    }
}
